import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Listener1 extends JFrame {

   public Listener1() {
      JButton open = new JButton("Open");
      JButton close = new JButton("Close");
      JButton save = new JButton("Save");
      getContentPane().setLayout(new FlowLayout());
      getContentPane().add(open);
      getContentPane().add(close);
      getContentPane().add(save);

      open.addActionListener(new OpenAction());
      close.addActionListener(new CloseAction());
      save.addActionListener(new SaveAction());

      pack();
      setVisible(true);
   }

   protected void open() {
      System.out.println("Open a file");
   }
   protected void close() {
      System.out.println("Close a file");
   }
   protected void save() {
      System.out.println("Save a file");
   }

   class OpenAction implements ActionListener {
      public void actionPerformed(ActionEvent e) {
         open();
      }
   }

   class CloseAction implements ActionListener {
      public void actionPerformed(ActionEvent e) {
         close();
      }
   }

   class SaveAction implements ActionListener {
      public void actionPerformed(ActionEvent e) {
         save();
      }
   }

   public static void main(String[] args) {
      new Listener1();
   }

}
